package com.example.product.statemachine;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @GetMapping("/create")
    public String create() {
        return orderService.create().getOrderId().toString();
    }

    @GetMapping("/pay/{id}")
    public String create(@PathVariable("id") Long orderId) {
        System.out.println("----------------create----------");
        return orderService.pay(orderId).getOrderId().toString();

    }

    @GetMapping("/deliver/{id}")
    public String deliver(@PathVariable("id") Long orderId) {
        return orderService.deliver(orderId).getOrderId().toString();

    }

    @GetMapping("/receive/{id}")
    public String receive(@PathVariable("id") Long orderId) {
        return orderService.receive(orderId).getOrderId().toString();

    }

}
